package com.home.a555clock

import android.content.Context
import android.util.Log
import android.widget.Toast
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.home.a555clock.MainActivity2.Companion.context
import com.home.a555clock.MainActivity2.Companion.restTime

class MyWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
  override fun doWork(): Result {
    Log.e("zzm debug","doWork start $restTime")
    Thread.sleep(3*1000)
    /*if(context == null){
      Log.e("zzm debug","context null")
    }else{
      MainActivity.notify(context!!)
    }*/
    Log.e("zzm debug","doWork end")
    Toast.makeText(context, "123", Toast.LENGTH_SHORT).show()
    return Result.success()
  }

  /*private val soundID:HashMap<Int?, Int?> = HashMap()
  private var mPresentPlayId:Int = 0
  private var soundPool:SoundPool? = null
  fun initSoundPool(){
    soundPool = SoundPool(2, AudioManager.STREAM_SYSTEM, 5)
    soundID[1] = soundPool?.load(applicationContext, R.raw.alarm, 1);//sos按钮
  }

  fun playAlarm(){
    if(soundPool == null){
      initSoundPool()
    }

    //soundPoolStop();
    mPresentPlayId = soundPool?.play(
      soundID[1]!!, 1f, 1f, 0, -1, 1f
    )!!
  }*/
}